package afk.biglog.gui;

import java.awt.*;

import javax.swing.*;
import javax.swing.border.*;
import javax.swing.table.*;

public class BlockCellRenderer implements TableCellRenderer
{

	@Override
	public Component getTableCellRendererComponent(final JTable table, final Object value, final boolean isSelected, final boolean hasFocus, final int row, final int column)
	{
		final JTextArea editor = new JTextArea();
		if (isSelected)
		{
			editor.setForeground(table.getSelectionForeground());
			editor.setBackground(table.getSelectionBackground());
		}
		else
		{
			editor.setForeground(table.getForeground());
			editor.setBackground(table.getBackground());
		}
		editor.setFont(table.getFont());

		if (hasFocus)
		{
			editor.setBorder(UIManager.getBorder("Table.focusCellHighlightBorder"));
			if (table.isCellEditable(row, column))
			{
				editor.setForeground(UIManager.getColor("Table.focusCellForeground"));
				editor.setBackground(UIManager.getColor("Table.focusCellBackground"));
			}
		}
		else
			editor.setBorder(new EmptyBorder(1, 2, 1, 2));
		if (value instanceof String)
			editor.setText((String) value);

		return editor;
	}
}
